import xbmcplugin
import xbmcaddon

def getSetting(arg,name):
    __settings__ = xbmcaddon.Addon()
    return __settings__.getSetting(name)


def getUserSettingAltPlayer(arg):
    uap = getSetting(arg,'useAltPlayer')
    v = False
    if(uap == "0"):
        v = True
    if(uap == "1"):
        v = False
    return v

def getUserSettingOSX(arg):
    osx = getSetting(arg,'isOSX')
    v = False
    if(osx == "0"):
        v = True
    if(osx == "1"):
        v = False
    return v

def getUserSettingCaUser(arg):
    cau = getSetting(arg,'caUser')
    v = False
    if(cau == "0"):
        v = True
    if(cau == "1"):
        v = False
    return v

def getUserSettingExpandEpisodes(arg):
    #no longer used, return False
    ee = getSetting(arg,'expandEpisodes')
    v = False
    return False
    if(ee == "0"):
        v = True
    if(ee == "1"):
        v = False
    return v


def getUserSettingDebug(arg):
    deb = getSetting(arg,'debug')
    v = False
    if(deb == "0"):
        v = True
    if(deb == "1"):
        v = False
    return v

def getUserSettingVerboseUserInfo(arg):
    vui = getSetting(arg,'verboseuser')
    v = False
    if(vui == "0"):
        v = True
    if(vui == "1"):
        v = False
    return v

def getUserSettingAppendYear(arg):
    ay = getSetting(arg,'appendYear')
    v = False
    if(ay == "0"):
        v = True
    if(ay == "1"):
        v = False
    return v

def getUserSettingYearLimit(arg):
    ylim = getSetting(arg, 'yearLimit')
    return str(ylim)

def getUserSettingMinYear(arg):
    ylim = getSetting(arg, 'minYear')
    if (ylim == ""):
        ylim = 0
    return int(ylim)

def getUserSettingMaxYear(arg):
    ylim = getSetting(arg, 'maxYear')
    if (ylim == ""):
        ylim = 0
    return int(ylim)

def getUserSettingMinMpaa(arg):
    ylim = getUserSettingRatingLimit(arg, 'minMpaa')
    return ylim

def getUserSettingMaxMpaa(arg):
    ylim = getUserSettingRatingLimit(arg, 'maxMpaa')
    return ylim

def getUserSettingMinRank(arg):
    ylim = getSetting(arg, 'minRank')
    return int(ylim)

def getUserSettingShowRatingInTitle(arg):
    ay = getSetting(arg,'showRatingInTitle')
    v = False
    if(ay == "0"):
        v = True
    if(ay == "1"):
        v = False
    return v

def getUserSettingPosterQuality(arg):
    pqs = getSetting(arg,'pQuality')
    
    v = "ghd"
    if(pqs == "0"):
        v = "ghd"
    if(pqs == "1"):
        v =  "large"
    if(pqs == "2"):
        v =  "medium"
    if(pqs == "3"):
        v =  "small"
    return v

def getUserSettingRatingLimit(arg,name):
    __settings__ = xbmcaddon.Addon()
    maxr = __settings__.getSetting(name)
    
    if(maxr == "0"):
        v = "0"
    elif(maxr == "1"):
        v =  "1000"
    elif(maxr == "2"):
        v =  "130"
    elif(maxr == "3"):
        v =  "110"
    elif(maxr == "4"):
        v =  "100"
    elif(maxr == "5"):
        v =  "90"
    elif(maxr == "6"):
        v =  "80"
    elif(maxr == "7"):
        v =  "75"
    elif(maxr == "8"):
        v =  "60"
    elif(maxr == "9"):
        v =  "50"
    elif(maxr == "10"):
        v =  "40"
    elif(maxr == "11"):
        v =  "20"
    elif(maxr == "12"):
        v =  "10"
    return int(v)

def getUserSettingGenreDisplay(arg, sgGenre):
    vui = getSetting(arg, str(sgGenre))
    v = False
    if(vui == "0"):
        v = True
    if(vui == "1"):
        v = False
    return v

def getUserSettingMaxIQRetreve(arg):
    maxr = getSetting(arg,'maxIqR')
    v = ""
    if(maxr == "0"):
        v = "10"
    if(maxr == "1"):
        v =  "25"
    if(maxr == "2"):
        v =  "50"
    if(maxr == "3"):
        v =  "75"
    if(maxr == "4"):
        v =  "100"
    if(maxr == "5"):
        v =  "200"
    if(maxr == "6"):
        v =  "300"
    if(maxr == "7"):
        v =  "400"
    if(maxr == "8"):
        v =  "500"
    return v
